package cn.com.cabinet.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.cabinet.web.entity.Cabinet;

public interface CabinetDao extends JpaRepository<Cabinet, Long>,JpaSpecificationExecutor<Cabinet>{

	@Query(nativeQuery=true,value="select * from ict_cabinet where cMark=1 and cCode=1 and cClass=?1 LIMIT ?2,?3")
	public List<Cabinet> getCabinetByNoneMark(String cClass,Integer page,Integer limit);
	
	@Query(nativeQuery=true,value="select count(*) from ict_cabinet where cMark=1 and cCode=1 and cClass=?1")
	public int getCabinetCountByNoneMark(String cClass);
	
	@Query(nativeQuery=true,value="select * from ict_cabinet where sellerId=?1 and cClass=?2 LIMIT ?3,?4")
	public List<Cabinet> getCabinetBySellerid(Long sellerId,String cClass,Integer page,Integer limit);
	
	@Query(nativeQuery=true,value="select count(*) from ict_cabinet where sellerId=?1 and cClass=?2")
	public int getCabinetCountBySellerid(Long sellerId,String cClass);
	
	@Query(nativeQuery=true,value="select * from ict_cabinet where sellerId=?1 LIMIT ?2,?3")
	public List<Cabinet> getCabinetBySellerid(Long sellerId,Integer page,Integer limit);
	
	@Query(nativeQuery=true,value="select count(*) from ict_cabinet where sellerId=?1")
	public int getCabinetCountBySellerid(Long sellerId);
	
}
